
"use strict";
var timeout;
app.controller("AnalysisProcessController", ["$scope", "$modal", "$timeout", "RESTService",
                                    function($scope,   $modal,   $timeout,   RESTService) {
	
	$scope.dtOptions = {
            "bLengthChange": false,
            "ordering": false,
            //"bFilter": false,
            "searching": true,
            /*"searchCols": [
            null,
            null,
            {   "search": "" },
            null,
            null
          ],
          "columns": [
	          {   "searchable": false },
	          {   "searchable": false },
	          null,
	          {   "searchable": false },
	          {   "searchable": false }
          ],*/
            
            "columnDefs": [               
               {
                 "targets": [ 4 ],
                 "visible": false
               }
             ],
          
          fnInitComplete: function() {
              $scope.dtInstance = this.fnSetFilteringDelay();
          }
    }
    
	//2、load user roles
	$scope.userTypes = [{key: "", cnName: "用户类型", enName: "User Type"}];
	RESTService.getResponse("/rest/usertype/getUserTypes?").then(function(response) {
		angular.forEach(response, function(value) {
            this.push({
            	key: value.userTypeId,
            	cnName: value.userTypeCnName,
            	enName: value.userTypeEnName
            });
        }, $scope.userTypes);
    });
	
	$scope.selectVal = "";//$scope.userTypes[0];
    $scope.selectXX = function () {
    	//alert($scope.selectVal);
    	//$scope.dtInstance.DataTable().ajax.reload();
    	//table.search( this.value ).draw();
    	console.log("2======$scope.selectVal: ", $scope.selectVal);
    	//$scope.selectVal = ($scope.selectVal==null ? $scope.userTypes[0] : $scope.selectVal);
    	$scope.selectVal = ($scope.selectVal==null ? "" : $scope.selectVal);
    	$scope.dtInstance.DataTable().columns(4).search( $scope.selectVal ).draw();
    }

    $scope.users = [];
    var loadUserListData = function() {
	    RESTService.getResponse("/rest/user/getUsers?userRole=all&like=" + "&pageNo=1&pageSize=1000000")
	    	.then(function(response) {
	    		$scope.users = response;
	    });
    }
    $scope.init = function() {
    	loadUserListData();
    }

}]);
